]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/icon: Check icon properties for changes before regenerating texture
authorJonas Dreßler <verdre@v0yd.nl>
Thu, 23 Jan 2020 09:44:30 +0000 (10:44 +0100)
committerMarge Bot <marge-bot@gnome.org>
Fri, 30 Jul 2021 13:59:18 +0000 (13:59 +0000)
Properly compare the new icon properties of StIcon to the old ones on
style-changes and only update the icon texture in case something
changed. This should help reduce the amount of texture cache requests
when we start emitting all "style-changed" signals again.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/953>

src/st/st-icon.c

index c54fe9d724f6915f28ae2ee824ff2e177b4c6586..6a93481792e4fc10b77f1d7ad0a87ba093648dc3 100644 (file)
@@ -60,6 +60,8 @@ struct _StIconPrivate
   gint             icon_size;       /* icon size we are using */
   GIcon           *fallback_gicon;
 
+  StIconColors     *colors;
+
   CoglPipeline    *shadow_pipeline;
   StShadow        *shadow_spec;
   graphene_size_t  shadow_size;
@@ -169,6 +171,7 @@ st_icon_dispose (GObject *gobject)
 
   g_clear_object (&priv->gicon);
   g_clear_object (&priv->fallback_gicon);
+  g_clear_pointer (&priv->colors, st_icon_colors_unref);
   g_clear_pointer (&priv->shadow_pipeline, cogl_object_unref);
   g_clear_pointer (&priv->shadow_spec, st_shadow_unref);
 
@@ -212,22 +215,46 @@ st_icon_style_changed (StWidget *widget)
   StIcon *self = ST_ICON (widget);
   StThemeNode *theme_node = st_widget_get_theme_node (widget);
   StIconPrivate *priv = self->priv;
+  gboolean should_update = FALSE;
+  g_autoptr(StShadow) shadow_spec = NULL;
+  StIconColors *colors;
 
-  st_icon_clear_shadow_pipeline (self);
-  g_clear_pointer (&priv->shadow_spec, st_shadow_unref);
-
-  priv->shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow");
+  shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow");
 
-  if (priv->shadow_spec && priv->shadow_spec->inset)
+  if (shadow_spec && shadow_spec->inset)
     {
       g_warning ("The icon-shadow property does not support inset shadows");
-      st_shadow_unref (priv->shadow_spec);
-      priv->shadow_spec = NULL;
+      g_clear_pointer (&shadow_spec, st_shadow_unref);
+    }
+
+  if ((shadow_spec && priv->shadow_spec && !st_shadow_equal (shadow_spec, priv->shadow_spec)) ||
+      (shadow_spec && !priv->shadow_spec) || (!shadow_spec && priv->shadow_spec))
+    {
+      st_icon_clear_shadow_pipeline (self);
+
+      g_clear_pointer (&priv->shadow_spec, st_shadow_unref);
+      priv->shadow_spec = g_steal_pointer (&shadow_spec);
+
+      should_update = TRUE;
+    }
+
+  colors = st_theme_node_get_icon_colors (theme_node);
+
+  if ((colors && priv->colors && !st_icon_colors_equal (colors, priv->colors)) ||
+      (colors && !priv->colors) || (!colors && priv->colors))
+    {
+      g_clear_pointer (&priv->colors, st_icon_colors_unref);
+      priv->colors = st_icon_colors_ref (colors);
+
+      should_update = TRUE;
     }
 
   priv->theme_icon_size = (int)(0.5 + st_theme_node_get_length (theme_node, "icon-size"));
-  st_icon_update_icon_size (self);
-  st_icon_update (self);
+
+  should_update |= st_icon_update_icon_size (self);
+
+  if (should_update)
+    st_icon_update (self);
 }
 
 static void